<?php

namespace core\middleware\uc;

use app\bll\UserLogregConfig as BllUserLogregConfig;
use Exception;
use support\View;
use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;

/**
 * UCenter 关闭 拦截器
 */
class RegClosedIntercept implements MiddlewareInterface
{
    public function process(Request $request, callable $handler): Response
    {

        $bllUserLogregConfig = new BllUserLogregConfig();
        $logregconfig        = $bllUserLogregConfig->find();
        if ($logregconfig['openreg'] == -1) {
            throw new Exception('注册功能已关闭');
        }
        return $handler($request);
    }
}
